package com.yilu.driver.mvp.presenter;


import android.content.Context;

import com.is.common.retrofitrxcache.RxCacheResult;
import com.is.common.rx.RxSubscriber;
import com.yilu.driver.entity.BatchAllResponse;
import com.yilu.driver.entity.RegisteredTraineeResponse;
import com.yilu.driver.mvp.contract.RegisterTraineeContract;

import org.json.JSONObject;


/**
 * @author Administrator
 * @date 2017/4/13 0013
 */

public class RegisterTraineePresenter extends RegisterTraineeContract.Presenter {
    private Context mContext;

    public RegisterTraineePresenter(Context mContext) {
        this.mContext = mContext;
    }

    @Override
    public void getUnRegisterTrainee(JSONObject json) {
        mRxManager.add(mModel.getUnRegisterTrainee(json).subscribe(new RxSubscriber<RxCacheResult<RegisteredTraineeResponse>>(mContext, false) {
            @Override
            protected void _onNext(RxCacheResult<RegisteredTraineeResponse> unRegisteredTraineeRxCacheResult) {
                mView.returnUnRegisterList(unRegisteredTraineeRxCacheResult.getResultModel());
            }

            @Override
            protected void _onError(String message) {

            }
        }));
    }

    @Override
    public void getRegisterTrainee(JSONObject json) {
        mRxManager.add(mModel.getRegisterTrainee(json).subscribe(new RxSubscriber<RxCacheResult<RegisteredTraineeResponse>>(mContext, false) {
            @Override
            protected void _onNext(RxCacheResult<RegisteredTraineeResponse> unRegisteredTraineeRxCacheResult) {
                mView.returnUnRegisterList(unRegisteredTraineeRxCacheResult.getResultModel());
            }

            @Override
            protected void _onError(String message) {

            }
        }));
    }

    @Override
    public void getBatchAll(JSONObject json) {
        mRxManager.add(mModel.getBatchAll(json).subscribe(new RxSubscriber<RxCacheResult<BatchAllResponse>>(mContext, false) {
            @Override
            protected void _onNext(RxCacheResult<BatchAllResponse> batchAllResponseRxCacheResult) {
                mView.returnBatchAll(batchAllResponseRxCacheResult.getResultModel());
            }

            @Override
            protected void _onError(String message) {

            }
        }));
    }
}
